using System;
using System.Xml;
using TDUnit.Common.TestDataParser;

namespace TDUnit.TestDataParsers.XmlParser
{
    public class XmlTestDataParserException : TestDataParserException 
    {
        public XmlTestDataParserException()
        {
        }

        public XmlTestDataParserException(string message)
            : base(message)
        {
        }

        public XmlTestDataParserException(string message, IXmlLineInfo lineInfo) : base(CreateExMessage(message, lineInfo))
        {
        }

        public XmlTestDataParserException(string message, IXmlLineInfo lineInfo, Exception innerException) : base(CreateExMessage(message, lineInfo), innerException)
        {
        }

        private static string CreateExMessage(string exMessage, IXmlLineInfo lineInfo)
        {
            return lineInfo.HasLineInfo() ?
                                              string.Format("{0} Line: {1}, Position: {2}", exMessage, lineInfo.LineNumber, lineInfo.LinePosition) :
                                                                                                                                                       exMessage;
        }
    }
}